# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: j605

_name=pyperf
pkgname='python-perf'
pkgver=2.5.0
pkgrel=2
pkgdesc='Toolkit to run Python benchmarks'
url='https://github.com/psf/pyperf'
arch=('any')
license=('MIT')
depends=('python' 'python-psutil')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
provides=(python-pyperf)
source=($url/archive/$pkgver/$_name-$pkgver.tar.gz)
sha512sums=('e4e873fa041de2b8aa866927d8a8af2438495e7ef48e2a6871a0c40048453ec30e80d94d0c19a0ed1603d2fe29d924cf19cbc2a32eb3e2e976c56d9c4a36f88e')
b2sums=('c015eb823dda5995ae097d19355f6f55b6b5230c2268c33493064fa42fa07ca6e1a19ceb727809769e978529cca58850f8b9f9e521a556ae4497b805183d049f')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"

  python -m unittest discover -s $_name/tests/ -v
}

package(){
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
